<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="box">
        <myslot>
            <template v-slot:header="obj">
                <div>
                    新写法：具名槽口 header {{obj}}
                    <span v-for="item in obj.slotarr" style="color: red;">
                        {{item}}
                    </span>
                </div>
            </template>
        </myslot>
        <myslot>
            <template v-slot:header="myobj">
                <div>
                    新写法：具名槽口 header
                    <span v-for="item in myobj.slotarr" style="color: blue;">
                    {{item}}
                    </span>
                </div>
            </template>
        </myslot>
    </div>
    <template id="myslotT">
        <div>
            <slot name="header" :msg="msg" :slotarr="arr"></slot>
        </div>
    </template>
    <script src="./js/vue.js"></script>
    <script>
        let vm = new Vue({
            el: "#box",
            data: {},
            components: {
                myslot: {
                    template: "#myslotT",
                    data() {
                        return {
                            msg: "slot内的msg数据",
                            arr: ["zhangsan", "lisi", "wangwu"]
                        }
                    }
                }
            }
        })
    </script>
    <!-- 
        数据是一样的，但是样式是不确定的，可以由调用者来决定。
     -->
</body>

</html>